<template>
  <div>
    <e-operation v-if="operationShow"
                 :btns="btns"
                 v-on="$listeners" />
    <e-search v-if="searchShow"
              :form-options="searchFormOptions"
              :form-label-width="searchLabelWidth"
              :refresh-show="searchRefreshShow"
              :insert-show="searchInsertShow"
              @on-search="handleSearch"
              @on-refresh="handleRefresh"
              @on-insert="handleInsert"
              @change-height="handleOpen"
              @changeSelect="changeSelect" />
  </div>
</template>

<script>
import eSearch from '@/components/e-search'
import eOperation from '@/components/e-operation'
export default {
  name: 'e-control',
  components: {
    eSearch,
    eOperation
  },
  props: {
    // 查询表单配置
    searchFormOptions: {
      type: Array,
      default () {
        return []
      }
    },
    // 查询表单label宽度
    searchLabelWidth: {
      type: String,
      default: '80px'
    },
    // 查询区是否展示重置按钮
    searchRefreshShow: {
      type: Boolean,
      default: true
    },
	searchInsertShow: {
	  type: Boolean,
	  default: false
	},
    // 操作区按钮配置
    btns: {
      type: Array,
      default () {
        return []
      }
    },
    // 搜索区是否显示
    searchShow: {
      type: Boolean,
      default: true
    },
    // 操作区是否显示
    operationShow: {
      type: Boolean,
      default: true
    }, 
  },
  data () {
    return {}
  },
  watch: {},
  computed: {},
  methods: {
    /**
     * @functionName handleSearch
     * @param {Object} data 查询表单数据
     * @description 点击查询按钮
     * @author 张航
     * @date 2020-10-13 08:50:50
     * @version V1.0.0
     */
    handleSearch (data) {
      this.$emit('on-search', data)
    },
    /**
     * @functionName handleRefresh
     * @param {Object} data 查询表单数据
     * @description 点击重置按钮
     * @author 张航
     * @date 2020-10-13 08:51:55
     * @version V1.0.0
     */
    handleRefresh (data) {
      this.$emit('on-refresh', data)
    },
	handleInsert (data) {
	  this.$emit('on-insert', data)
	},
    /**
     * @functionName handleOpen
     * @param {Number} height 查询表单的高度
     * @description 点击展开/关闭按钮
     * @author 张航
     * @date 2020-10-13 08:52:35
     * @version V1.0.0
     */
    handleOpen (height) {
      this.$emit('change-height', height + (this.operationShow ? 50 : 0))
    },
    changeSelect (data) {
      this.$emit('changeSelect', data)
    }
	
  },
  created () { },
  mounted () { }
}
</script>
<style lang="scss" scoped>
</style>
